//
//  Handel.swift
//  DanTangLKM
//
//  Created by LKM on 16/8/31.
//  Copyright © 2016年 LKM. All rights reserved.
//

import UIKit

open class Handler {

    /*
    // Only override drawRect: if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func drawRect(rect: CGRect) {
        // Drawing code
    }
    */
    
    open class func ss(_ run:() -> Void){
        run();
    }
    
    open class func post(_ run:@escaping () -> Void){
         DispatchQueue.main.async { run() }
        
    }
    /**
     秒
     */
    class func postDelayed(_ delay:Float, closure:@escaping ()->()) {
        DispatchQueue.main.asyncAfter(
            deadline: DispatchTime.now() + Double(Int64(delay * Float(NSEC_PER_SEC))) / Double(NSEC_PER_SEC), execute: closure)
    }
    
//    public class func postDelayed(run:() -> Void,delaySeconds:Float){
//        
////        Int64()
//        
//        dispatch_after( dispatch_time(DISPATCH_TIME_NOW, (Int64)(10 * NSEC_PER_SEC)),dispatch_get_main_queue()) {
//                    
//            run();
//        }
//        
//    }
    
    var queue = OperationQueue()
    
    func testNSOperationQueue(){
            //func (op: NSOperation!)
            let mopt = myOperationThread()
           
            queue.addOperation(mopt)
        
        mopt.cancel();
    }
    
}


class myOperationThread : Operation{
    

    override func main()
    {
        
//        println("NSOperation over.")
    }
}

    
     


